Interface
Simulation results
Setting the backend
- class qmatchatea.utils.backend.QCBackend(precision='A', device='cpu', ansatz='MPS', mpi_settings=None, tensor_module='numpy')[source]
Backend for the simulation. Contains all the informations about which executable you want to run.
Parameters
- precision: str, optional
Precision of the simulation. Select a real precision ONLY if you use ONLY real gates. Available: - “A”: automatic. For the heuristic see self.resolve_precision. - “Z”: double precision complex; - “C”: single precision complex; - “D”: double precision real; - “S”: single precision real. Default to “A”.
- device: str, optional
Device of the simulation. Available: - “A” : automatic. For the heuristic see self.resolve_device - “cpu”: use the cpu - “gpu”: use the gpu if it is available - “cpu+gpu”: use the device-mixed mode (if gpu is available) Default to “A”.
- ansatzstr, optional
Whether to run the circuit with MPS or TTN tensor network ansatz. Default to “MPS”.
- mpi_settingsMPISettings | None, optional
Settings for running the simulation multi-node. Default to None, i.e. no MPI.
- tensor_modulestr, optional
Module used to perform the computations. Available: - “numpy” (Default, uses cupy for the GPU) - “torch”, uses pytorch; - “tensorflow” - “jax”. Default to “numpy”
- property ansatz
ansatz property
- property device
Device property
- classmethod from_json(path)[source]
Initialize the class from a json file called “backend.json” in the folder path
- property identifier
Identifier combining all properties.
- property mpi_approach
mpi_approach property (inherited from mpi_settings)
- property mpi_command
mpi_command property
- property num_procs
Number of processes property
- property precision
Precision property
- resolve_device(bond_dimension, previous_device, exp_gpu=7)[source]
Resolve the device if it set on automatic.
Parameters
- bond_dimensionint
Maximum bond dimension of the system
- previous_devicestr
Device where the system is currently. This is used to ensure we do not keep exchanging data back and forth.
- exp_gpuint, optional
Exponent of the bond dimension after which you switch to the gpu, i.e: - if chi >= 2**exp_gpu -> use gpu - if chi <= 2**(exp_gpu-1) -> use cpu Default to 7. (switch at 128)
Returns
- str
Device where to move (or keep) the system
- resolve_precision(min_fidelity, tol=1e-07)[source]
Resolve the precision of the simulation. Heuristic if self._precision=”A”.
Parameters
- min_fidelity: float
Lower bound of the fidelity of the simulation at the moment
- tol: float, optional
Tolerance after which you switch to single precision. Default to 1e-7
Returns
- str
The selected precision
- property where_barriers
This parameter is important only if you want to use MPI parallelization, where a barrier is equivalent to a canonization in the MPS simulation. Default to -1.